{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "017450a3",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "81f76b30",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    1.1\n",
       "1    2.2\n",
       "2    3.3\n",
       "dtype: float64"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s1 = pd.Series([1.1, 2.2, 3.3])\n",
    "s1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "39b68960",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "RangeIndex(start=0, stop=3, step=1)"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s1.index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "7b0b617e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "101      tom\n",
       "102    jerry\n",
       "105     tyke\n",
       "107    spark\n",
       "Name: cartoon movie, dtype: object"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "actors = ['tom', 'jerry', 'tyke', 'spark']\n",
    "ids = [101, 102, 105, 107]\n",
    "s2 = pd.Series(actors, index = ids, name=\"cartoon movie\")\n",
    "s2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "f679c76a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'jerry'"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s2[102] # 使用指定的索引访问 series内部的数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "021d19af",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "101     tom\n",
       "105    tyke\n",
       "Name: cartoon movie, dtype: object"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s2[::2] # 切片(整数/指定的索引)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "cecded07",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Int64Index([101, 102, 105, 107], dtype='int64')"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s2.index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "fd0b6223",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['tom', 'jerry', 'tyke', 'spark'], dtype=object)"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s2.values # 返回Series内部的值，值的类型是ndarray的"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "0b5157a2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(3,)"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data = {'105': '章三', '101': '里斯', '102': '王五'}\n",
    "s3 = pd.Series(data)\n",
    "s3.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "80642137",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
